#include "Unit.h"
#include <string>
#include <iostream>

Unit::Unit(int ratio, std::string name):ratioToBase_m(ratio), name_m(name)
{
}

int Unit::convertToUnit(int quantity, const Unit& unit)const
{
   return unit.ratioToBase_m!=0?ratioToBase_m*quantity/unit.ratioToBase_m:0;
}

int Unit::convertFromBaseUnit( int quantity ) const
{
   return ratioToBase_m!=0?quantity/ratioToBase_m:0;
}

std::ostream & operator << (std::ostream & ostr, const Unit& unit)
{
   ostr << unit.name_m;
   return ostr;
}


